//package org.arch_learn.servlet_container.servlet;
//
//import org.arch_learn.servlet_container.pojo.CustomHttpServletResponse;
//import org.arch_learn.servlet_container.utils.HttpProtocolUtil;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//public class GeneralServlet2 extends HttpServlet {
//    @Override
//    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        String content = "<h1>Servlet2 do get</h1>";
//        String messageText = HttpProtocolUtil.getHttp200ResponseHeader(content.getBytes().length) + content;
//        CustomHttpServletResponse response = (CustomHttpServletResponse) resp;
//        response.setMessageText(messageText);
//    }
//
//    @Override
//    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        String content = "<h1>Servlet2 do post</h1>";
//        String messageText = HttpProtocolUtil.getHttp200ResponseHeader(content.getBytes().length) + content;
//        CustomHttpServletResponse response = (CustomHttpServletResponse) resp;
//        response.setMessageText(messageText);
//    }
//
//    @Override
//    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        String content = "<h1>Servlet2 do put</h1>";
//        String messageText = HttpProtocolUtil.getHttp200ResponseHeader(content.getBytes().length) + content;
//        CustomHttpServletResponse response = (CustomHttpServletResponse) resp;
//        response.setMessageText(messageText);
//    }
//
//    @Override
//    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        String content = "<h1>Servlet2 do delete</h1>";
//        String messageText = HttpProtocolUtil.getHttp200ResponseHeader(content.getBytes().length) + content;
//        CustomHttpServletResponse response = (CustomHttpServletResponse) resp;
//        response.setMessageText(messageText);
//    }
//
//    @Override
//    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        System.out.println("---servlet2处理了请求url为" + req.getRequestURI() + "的请求---");
//        String method = req.getMethod();
//        switch (method) {
//            case "GET":
//                doGet(req, resp);
//                break;
//            case "POST":
//                doPost(req, resp);
//                break;
//            case "PUT":
//                doPut(req, resp);
//                break;
//            case "DELETE":
//                doDelete(req, resp);
//                break;
//        }
//    }
//}
